﻿package mortal.game.view.platform.platformTencent
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.nationalDayAct.*;
    import mortal.mvc.core.*;

    public class PlatformQQCategoryCellRender extends GCellRenderer
    {
        private var _categoryBg:ScaleBitmap;
        private var _categoryText:GImageBitmap;
        private var _categoryData:nationalDayActCategoryData;

        public function PlatformQQCategoryCellRender()
        {
            return;
        }// end function

        override protected function initSkin() : void
        {
            var _loc_1:* = new GBitmap();
            var _loc_2:* = UIFactory.bg(0, 0, 190, 68, null, ImagesConst.selectFilter);
            this.setStyle("downSkin", _loc_2);
            this.setStyle("overSkin", _loc_2);
            this.setStyle("upSkin", _loc_1);
            this.setStyle("selectedDownSkin", _loc_2);
            this.setStyle("selectedOverSkin", _loc_2);
            this.setStyle("selectedUpSkin", _loc_2);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._categoryBg = UIFactory.bg(4, 4, 182, 60, this, ImagesConst.AchievemenListTabBtnBg);
            this._categoryText = UIFactory.gImageBitmap("", 32, 21, this);
            Dispatcher.addEventListener(EventName.PlatformQQSwitchPanel, this.onSwitch);
            return;
        }// end function

        private function onSwitch(event:DataEvent) : void
        {
            if (this._categoryData.index == int(event.data))
            {
                this.selected = true;
            }
            else
            {
                this.selected = false;
            }
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._categoryData = param1 as nationalDayActCategoryData;
            if (this._categoryData)
            {
                this._categoryText.imgUrl = this._categoryData.resName;
                this._categoryText.x = this._categoryData.textXPos;
                this._categoryText.y = this._categoryData.textYPos;
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._categoryBg.dispose(param1);
            this._categoryText.dispose(param1);
            this._categoryBg = null;
            this._categoryText = null;
            this._categoryData = null;
            super.disposeImpl(param1);
            Dispatcher.removeEventListener(EventName.NationalDayActSwitchPanel, this.onSwitch);
            return;
        }// end function

    }
}
